/**************************************************************
  > File Name: 12.c
  > Author: LuoLiang
  > Mail: 1204553475@qq.com 
  > Created Time: 2022年01月25日 星期二 15时15分59秒
 **************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char * intToRoman(int num)
{
	int sum = 0;
	int cur = 0;
	const int vaule[] = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
	const char *symbols[] = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
	char *buff = malloc(sizeof(char) * 16);
	
	buff[0] = '\0';
	for (int i = 0; i < 13; i++)
	{
		while (num >= vaule[i])
		{
			num -= vaule[i];
			strcpy(buff + strlen(buff),symbols[i]);
		}
		if (num == 0)
			break;
	}	
	return buff;
}

int main(int argc,char **argv)
{
	int n;
	char *ret = NULL;

	scanf("%d",&n);
	ret = intToRoman(n);

	puts(ret);
    exit(0);
}




